package com.soft.product.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.soft.entity.TProduct;
import com.soft.service.TProductService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

@SpringBootTest
@RunWith(SpringRunner.class)
public class testTProductService {
    @Autowired
    TProductService tProductService;

    @Test
    public void testPageHelperQuery(){
//        PageHelper.startPage(0, 10);
//        List<TProduct> list = tProductService.findAllProdects();
//        PageInfo<TProduct> pageInfo = new PageInfo<TProduct>(list);
//        System.out.println(pageInfo.getList());
//        System.out.println(pageInfo);

//        System.out.println(tProductService.queryAllByPageHelper(0, 6));
        //pageNum是第几页，pageSize是按每页几个来分页
        System.out.println(tProductService.queryAllByPageHelper(1, 3));
        System.out.println(tProductService.queryAllByPageHelper(1, 3));
        System.out.println(tProductService.queryAllByPageHelper(2, 2));
    }

    @Test
    public void testvagueFindAllProducts(){
        System.out.println(tProductService.vagueFindAllProducts(1, 3, "dsa"));
        System.out.println(tProductService.vagueFindAllProducts(1, 3, "裙子"));

    }

}
